var siteinfo = require("../../siteinfo.js");

Page({

    /**
     * 页面的初始数据
     */
    data: {
        listData: [],
        page: '0',
        no_nore: '0'
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        let base_info = wx.getStorageSync('global_baseinfo')
        console.log(base_info.base_color)
        wx.setNavigationBarColor({
          backgroundColor: base_info.base_color,
          frontColor: '#000000',
        })
        this.getRoomList();
    },
    getRoomList: function () {
        var $this = this;
        wx.request({
            url: siteinfo.site_url + "api/live/getRoomList",
            data: {
                uniacid: siteinfo.uniacid,
                page: $this.data.page,
            },
            success: function (res) {
                var data = res.data;
                console.log(data.data);
                if (data.code == 1 && data.data) {
                    $this.setData({
                        listData: $this.data.listData.concat(data.data)
                    });
                }
                console.log($this.data.listData.length)
                if(data.data && data.data.length < 20){
                    $this.setData({
                        no_nore: 1
                    })
                }
            }
        })
    },
    onReachBottom: function () {
        var $this = this;
        console.log($this.no_nore);
        if($this.no_nore!=1){
            $this.setData({
                page: $this.data.page+1
            });
            $this.getRoomList();
        }
    }
});